<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var str = '今天,的,天气,真不错';
        var arr = str.split(',');
        // ['今天','的','天气','真不错']
        //    0     1     2      3
        // 获取“天气”
        console.log(arr[2]);
        console.log('---------------------')
        var str = '马云 1351111111 四川省 成都市 金牛区 九里堤北路xxx号';
        var arr = str.split(' ');
        console.log(arr);
        console.log('----------------------')
        function getStudyTime(str) {
            var arr = str.split(',');
            var time = arr[5]; // 此处任然是一个字符串
            return parseFloat(time);
        }
        var allString = `Id,学员姓名,专业,学习课程,签到时间,学习时长
1,李文强,软件,JavaScript,2020-03-27 09:21:44,45
2,李文强,软件,JavaScript,2020-03-27 10:21:45,46
3,李文强,软件,JavaScript,2020-03-27 11:21:46,47
4,李文强,软件,JavaScript,2020-03-27 12:21:47,48
5,李文强,软件,JavaScript,2020-03-27 13:21:48,49
6,李文强,软件,JavaScript,2020-03-27 14:21:49,50
7,李文强,软件,JavaScript,2020-03-27 15:21:50,51
8,李文强,软件,JavaScript,2020-03-27 16:21:51,52
9,李文强,软件,JavaScript,2020-03-27 17:21:52,53`;
        var lines = allString.split("\n");// 使用换行分割
        var sum = 0;
        for (var i = 1; i < lines.length; i++) {

            console.log(lines[i]);
            var time = getStudyTime(lines[i]); // 获取到每一行文字的时长
            //为什么会出现NaN
            sum += time;
        }
        console.log(sum);
    </script>
</body>

</html>